package pc;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;

public class InputHandler implements Runnable {

	private BufferedReader in = null;
	private DataOutputStream out = null;
	
	public InputHandler(InputStream i, DataOutputStream d) {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = d;
	}
	
	public void run() {
		try {
			String tmp = in.readLine();
			while (!tmp.equals("q")) {
				if (tmp.equals("s")) {
					System.out.print("Sending start...");
					out.writeByte(1);
					out.flush();
					System.out.println("done");
				}
				tmp = in.readLine();
			}
			out.writeByte(0);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
